package cn.woniu.ecommerceplatform.controller;

import cn.woniu.ecommerceplatform.entity.QueryCustomer;
import cn.woniu.ecommerceplatform.service.CustomerService;
import cn.woniu.ecommerceplatform.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/blackList")
public class BlackListController {
    @Autowired(required = false)
    private CustomerService service;

    @PostMapping("/showList")
    @PreAuthorize("hasAnyAuthority('customer:queryblack')")
    public ResponseResult<?> showAll(@RequestBody QueryCustomer queryCustomer){
    return service.queryBlackList(queryCustomer.getPhone(),queryCustomer.getName(),queryCustomer.getPageNo(),queryCustomer.getPageSize());
    }
    @RequestMapping("/removeList")
    @PreAuthorize("hasAnyAuthority('customer:outblack')")
    public ResponseResult<?> removeBlackList(String account){
        return service.removeBlackList(account);
    }
}
